// eslint-disable-next-line
import { UserLayout, BasicLayout, BlankLayout } from '@/layouts'

const RouteView = {
  name: 'RouteView',
  render: h => h('router-view')
}

export const asyncRouterMap = [
  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: { title: '主页' },
    redirect: '/home/basic',
    children: [
      // 主页
      {
        path: '/home',
        name: 'home',
        component: RouteView,
        redirect: '/home/basic',
        meta: { title: '主页', icon: 'home', permission: ['home'] },
        children: [
          {
            path: '/home/basic',
            name: 'homeBasic',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/home/Home'),
            meta: { title: '基础信息', icon: 'profile', keepAlive: true, permission: ['home-basic'] }
          }
        ]
      },

      // 投票管理
      {
        path: '/manage',
        name: 'manage',
        component: RouteView,
        redirect: '/manage/project',
        meta: { title: '投票管理', icon: 'control', permission: ['manage'] },
        children: [
          {
            path: '/manage/project',
            name: 'manageProject',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/manage/Project'),
            meta: { title: '项目管理', icon: 'project', keepAlive: false, permission: ['manage'] }
          },
          {
            path: '/manage/judge',
            name: 'manageJudge',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/manage/Judge'),
            meta: { title: '评委管理', icon: 'user', keepAlive: false, permission: ['manage'] }
          },
          {
            path: '/manage/candidate',
            name: 'manageCandidate',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/manage/Candidate'),
            meta: { title: '候选人管理', icon: 'user', keepAlive: false, permission: ['manage'] }
          },
          {
            path: '/manage/voteList',
            name: 'voteList',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/manage/VoteList'),
            meta: { title: '投票日志', icon: 'menu', keepAlive: false, permission: ['manage'] }
          },
          // {
          //   path: '/manage/selectFiles',
          //   name: 'selectFiles',
          //   hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
          //   component: () => import('@/views/manage/modules/SelectFiles'),
          //   meta: { title: '文件上传测试', icon: 'file', keepAlive: true, permission: ['manage'] }
          // },
          // {
          //   path: '/manage/downloadFiles',
          //   name: 'downloadFiles',
          //   hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
          //   component: () => import('@/views/manage/modules/DownloadFiles'),
          //   meta: { title: '文件下载测试', icon: 'file', keepAlive: false, permission: ['manage'] }
          // }
        ]
      },
      // 开始投票
      {
        path: '/list',
        name: 'list',
        component: RouteView,
        redirect: '/list/project',
        meta: { title: '开始投票', icon: 'table', permission: ['list'] },
        children: [
          {
            path: '/list/project',
            name: 'listProject',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import('@/views/list/Project'),
            meta: { title: '项目投票', icon: 'project', keepAlive: true, permission: ['list-project'] }
          },
          // {
          //   path: '/list/candidate',
          //   name: 'listCandidate',
          //   hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
          //   component: () => import('@/views/list/Candidate'),
          //   meta: { title: '候选人选择', icon: 'user', keepAlive: true, permission: ['list-candidate'] }
          // }
        ]
      },

      // forms
      {
        path: '/form',
        redirect: '/form/base-form',
        component: RouteView,
        meta: { title: '表单页', icon: 'form', permission: ['form'] },
        children: [
          {
            path: '/form/base-form',
            name: 'BaseForm',
            component: () => import('@/views/form/basicForm'),
            meta: { title: '基础表单', keepAlive: true, permission: ['form'] }
          },
          {
            path: '/form/step-form',
            name: 'StepForm',
            component: () => import('@/views/form/stepForm/StepForm'),
            meta: { title: '分步表单', keepAlive: true, permission: ['form'] }
          },
          {
            path: '/form/advanced-form',
            name: 'AdvanceForm',
            component: () => import('@/views/form/advancedForm/AdvancedForm'),
            meta: { title: '高级表单', keepAlive: true, permission: ['form'] }
          }
        ]
      },

      // result
      {
        path: '/result',
        name: 'result',
        component: RouteView,
        redirect: '/result/success',
        meta: { title: '结果页', icon: 'check-circle-o', permission: ['result'] },
        children: [
          {
            path: '/result/success',
            name: 'ResultSuccess',
            component: () => import(/* webpackChunkName: "result" */ '@/views/result/Success'),
            meta: { title: '成功', keepAlive: false, hiddenHeaderContent: true, permission: ['result'] }
          },
          {
            path: '/result/fail',
            name: 'ResultFail',
            component: () => import(/* webpackChunkName: "result" */ '@/views/result/Error'),
            meta: { title: '失败', keepAlive: false, hiddenHeaderContent: true, permission: ['result'] }
          }
        ]
      },

      // Exception
      {
        path: '/exception',
        name: 'exception',
        component: RouteView,
        redirect: '/exception/403',
        meta: { title: '异常页', icon: 'warning', permission: ['exception'] },
        children: [
          {
            path: '/exception/403',
            name: 'Exception403',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/403'),
            meta: { title: '403', permission: ['exception'] }
          },
          {
            path: '/exception/404',
            name: 'Exception404',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404'),
            meta: { title: '404', permission: ['exception'] }
          },
          {
            path: '/exception/500',
            name: 'Exception500',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/500'),
            meta: { title: '500', permission: ['exception'] }
          }
        ]
      }
    ]
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login')
      },
    ]
  },

  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  }
]
